package com.jpxx.netty.chaibao2;


import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
import io.netty.util.ReferenceCountUtil;

  
public class ClientHandler extends ChannelHandlerAdapter{  


	@Override  
	public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {  
		try {
			System.out.println("客户端读取信息:"+ msg.toString()); 
		} finally{
			ReferenceCountUtil.release(msg);//ByteBuf释放它
		}
	}
	
	
	@Override  
	public void channelActive(ChannelHandlerContext ctx) {  
		//System.out.println("客户端启动！");  
	}  

	@Override
	public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
		//System.out.println("读取完毕");  
	}

	@Override  
	public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {  
		cause.printStackTrace();  
		ctx.close();  
	}  

}  
